import { TodoType } from './store'
export type ActionType = {
  type: string
  payload?: any //附加内容 例如：要新增的内容， 要删除的list中的内容     的 id
}
export default function reducer(state: TodoType[], actions: ActionType) {
  switch (actions.type) {
    case 'add':
      return state.concat(actions.payload)
    case 'delete':
      return state.filter(todo => {
        return todo.id !== actions.payload
      })
    default:
      throw new Error('报错')
  }
}
